//
//  HomePageScrollTableViewCell.m
//  u76ho
//
//  Created by m-air-01 on 16/1/20.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "HomePageScrollTableViewCell.h"
#import "HPSCollectionViewCell.h"
#import "HomePageModel.h"
#import "CommendCompanyModel.h"
@interface HomePageScrollTableViewCell ()
<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
{
    CGSize size;
}
@end
@implementation HomePageScrollTableViewCell

- (void)awakeFromNib {
    // Initialization code
    size = CGSizeMake(140, 83);
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    [_collectionView registerNib:[UINib nibWithNibName:@"HPSCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"HPSCollectionViewCell"];
}
-(void)setPicArr:(NSArray *)picArr
{
    _picArr = picArr;
    [_collectionView reloadData];
}
#pragma mark - _collectionDelegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _picArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    HPSCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HPSCollectionViewCell" forIndexPath:indexPath];
    if ([_picArr.firstObject isKindOfClass:[CommendCompanyModel class]]) {
        CommendCompanyModel * model = _picArr[indexPath.item];
        [cell.headerImgV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",U76HOURL,model.Headpic]] placeholderImage:[UIImage imageNamed:@"发现－默认logo.png"]];
        cell.firstLab.text = model.Username;
        //cell.secondLab.text = model.industry;
    }
    else
    {
        
    }
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (_collectionCellselectedBlock) {
        _collectionCellselectedBlock((int)indexPath.item);
    }
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return size;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
